var t = getApp();

Page({
    data: {
        tabs: [],
        selected: 0,
        tabID: 0,
        bossList: [],
        detail: {},
        uid: 0,
        inNickName: "",
        showNoText: !1,
        diyName: "我的朋友",
        isLoadMore: !0,
        page: 1,
        current_page: 0,
        last_page: 0
    },
    onLoad: function(t) {
        this.getTab();
    },
    changeTab: function(t) {
        console.log(t), this.setData({
            selected: t.currentTarget.dataset.tab,
            tabID: t.currentTarget.dataset.tab,
            page: 1,
            bossList: ""
        }), this.getData();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        if (this.data.current_page >= this.data.last_page) wx.showToast({
            title: "没有更多",
            icon: "none",
            duration: 1e3
        }); else {
            var t = this.data.page + 1;
            this.setData({
                page: t
            }), console.log(this.data.page), this.getMoreData();
        }
    },
    onShareAppMessage: function() {},
    getTab: function() {
        var a = this, e = t.getNetAddresss("plugin.my-friend.api.my-friend.get-columns");
        t._getNetWork({
            url: e,
            success: function(t) {
                var e = t.data;
                1 == e.result ? (console.log(e), a.setData({
                    tabs: e.data.columns,
                    tabID: e.data.columns[0].id,
                    diyName: e.data.my_friend_name ? e.data.my_friend_name : "我的朋友",
                    selected: e.data.columns[0].id
                }), a.getData()) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1e3
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getData: function() {
        var a = this, e = t.getNetAddresss("plugin.my-friend.api.my-friend.get-list");
        t._postNetWork({
            url: e,
            data: {
                id: a.data.tabID,
                page: a.data.page
            },
            success: function(e) {
                var s = e.data;
                if (1 == s.result) {
                    console.log(s);
                    var o = s.data.list.data;
                    a.setData({
                        showNoText: t._isTextEmpty(o),
                        bossList: o,
                        last_page: s.data.list.last_page,
                        current_page: s.data.list.current_page
                    });
                } else wx.showToast({
                    icon: "none",
                    title: s.msg,
                    duration: 1e3
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMoreData: function() {
        var a = this, e = t.getNetAddresss("plugin.my-friend.api.my-friend.get-list");
        t._postNetWork({
            url: e,
            data: {
                id: a.data.tabID,
                page: a.data.page
            },
            success: function(e) {
                var s = e.data;
                if (1 == s.result) {
                    console.log(s);
                    var o = s.data.list.data;
                    a.setData({
                        showNoText: t._isTextEmpty(o),
                        bossList: a.data.bossList.concat(o),
                        last_page: s.data.list.last_page,
                        current_page: s.data.list.current_page
                    });
                } else wx.showToast({
                    icon: "none",
                    title: s.msg,
                    duration: 1e3
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    }
});